{extend name="public/base"/}
{block name="style"}
<link href="__PUBLIC__/ieasy/css/detail.css?v=2.1.49" rel="stylesheet" type="text/css">
<script type="text/javascript">
<!--

	document.oncontextmenu=new Function("event.returnValue=false");
	document.onselectstart=new Function("event.returnValue=false");

//-->
</script>
{/block}
{block name="body"}
<body class="read_theme_2 ">
<div id="console_main"></div>
<!-- 这是正文 -->

<div class="read_body read_body_fontsize_2">
    <div class="read_content_list">
        <div class="read_main_box">
            <div class="read_tit_box">
                <a href="/personal/jubao" class="menu_position_101">举报</a>
                <h2>{$chaptername}</h2>
            </div>
            <div class="read_main_p"></div>
        </div>
        
        <div class="read_main_other_box">
				<!---
				<div style="margin-bottom:10px;margin-top:0px;display:none" id="subscribe-panel">
					<a class="weui_btn weui_btn_primary btn-subscribe" style="width:40%;" href="javascript:;">追 书</a>
				</div>
				---->
				{next articleid="$bookid" chapterid="$chapterid" model="chapter"}
                <a href="javascript:;" data-url="/chapter/read/{$bookid}/{$next['id']}.html" style=" position: static" class="btn-next-article read_nex_but menu_position_101">下一章</a>
				{/next}
                        <div class="read_other_box menu_position_101" style=" position: static">
				{if $chapterorder==1}
					<a href="javascript:;" class="read_other_but_l">上一章</a>
				{else}
				{prev articleid="$bookid" chapterid="$chapterid" model="chapter"}
				<a href="/chapter/read/{$bookid}/{$prev['id']}" class="read_other_but_l">上一章</a>
				{/prev}
                {/if}
                <span></span>
                <a href="javascript:;" class="read_other_but_l op_menu">菜单</a>
                           <span></span>
                <a href="/" class="read_other_but_l">首页</a>
               
                            </div>
        </div>
        <div style="padding-bottom: .5rem;" id=tuijian>
            {if $diyactive==1}
            {if $diypreferential_url!=''}
            <a href="{$diypreferential_url}">
                <img src="https://ossqingguo959.oss-cn-hangzhou.aliyuncs.com/public/activity/template6/guoqing.png" alt="国庆福利">
            </a>
            {/if}
            {/if}
        </div>
    </div>
</div>

<div style="position:fixed;bottom: 100px;right: 0;" id="vip-btn">
</div>
<!--read_body  阅读内容-->
<div class="menu_evocation_box" style="display: none;">
    <span></span>
    <strong></strong>
    <span></span>
</div>
<!--menu_evocation_box 唤出菜单点击区域框-->
<div class="menu_box menu_hide">
    <i></i>
        <a href="/personal/history" class="recent_reading_but">最近阅读</a>
        <div class="menu_footer">
        <div class="m_f_set_box">
            <div class="m_f_set_bg_box m_f_set_font_main" >
                <div class="m_f_set_bg_li_tit">字体</br/>大小</div>
                <div class="m_f_set_bg_li" id=font1>
                    <a href="javascript:;" data-size="small" class="fonthover">小</a>
                </div>
                <div class="m_f_set_bg_li" id=font2 >
                    <a href="javascript:;" data-size="medium"class="fonthover">中</a>
                </div>
                <div class="m_f_set_bg_li" id=font3>
                    <a href="javascript:;" data-size="large" class="fonthover">大</a>
                </div>
            </div>
            <div class="m_f_set_bg_box m_f_set_bg_main" id=bg>
                <div class="m_f_set_bg_li_tit">背景<br/>颜色</div>
                <div class="m_f_set_bg_li" id=bg1>
                    <a href="javascript:;" class="m_f_set_bg_but_1"></a>
                </div>
                <div class="m_f_set_bg_li" id=bg2>
                    <a href="javascript:;" class="m_f_set_bg_but_2"></a>
                </div>
                <div class="m_f_set_bg_li" id=bg3>
                    <a href="javascript:;" class="m_f_set_bg_but_3"></a>
                </div>
                <div class="m_f_set_bg_li" id=bg4>
                    <a href="javascript:;" class="m_f_set_bg_but_4"></a>
                </div>
            </div>
        </div>
        <!--m_f_set_box-->
        <div class="menu_footer_but">
			{if $chapterorder==1}
				<a href="javascript:;" class="m_f_prev">上一章</a>
			{else}
				{prev articleid="$bookid" chapterid="$chapterid" model="chapter"}
				<a href="/chapter/read/{$bookid}/{$prev['id']}" class="m_f_prev">上一章</a>
				{/prev}
			{/if}
            <a href="/book/chapter/{$bookid}" class="m_f_catalog">目录</a>
            <a href="javascript:;" class="m_f_set">设置</a>
            <a href="javascript:;" class="m_f_day m_f_night_day">白天</a>
            <a href="javascript:;" class="m_f_night m_f_night_day">夜间</a>
			{next articleid="$bookid" chapterid="$chapterid" model="chapter"}
            <a href="javascript:;" data-url="/chapter/read/{$bookid}/{$next['id']}.html" class="btn-next-article m_f_next">下一章</a>
			{/next}
        </div>
        <!--menu_footer_but-->
    </div>
    <!--menu_footer-->
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/ieasy/js/zepto.min.js?v=2.1.49"></script>
<script type="text/javascript" src="__PUBLIC__/ieasy/js/zepto.cookie.min.js?v=2.1.49"></script>

<!-- 这是zepto插件 -->

<script type="text/javascript" src="__PUBLIC__/ieasy/js/common.js?v=2.1.49"></script>

<link rel="stylesheet" href="__PUBLIC__/ieasy/css/vendor.css">
<link rel="stylesheet" href="__PUBLIC__/ieasy/css/front.css">
<script src="__PUBLIC__/ieasy/js/vendor.js?20170823"></script>
<script src="__PUBLIC__/ieasy/js/app.js"></script>
<script src="__PUBLIC__/ieasy/js/template.js"></script>
<script type="text/html" id="tuijian-novel-item">
  <% for(var i = 0; i < data.length; i++){ %>
  <a class="new-book-data" style="display: block; width: 95%; margin:0 auto; margin-bottom: 5px;" href="/index.php/cms/index/detail/id/<%= data[i]['id'] %>" style="display: inline-flex;align-items: center;padding-left: 4%;">
            <img style="width: 30px;height: 30px;border-radius: 3px;display: block;float: left; margin-right: 5px;" src="<%= data[i]['img'] %>">
            <span style="font-size:14px;color: #35a4d0;margin-left: 5px; line-height: 30px;"><%= data[i]['title'] %></span>
            </a>
            <div style="clear:both"></div>

  <% } %> 
</script>

<script>
	var qiandao  = '{$qiandao|default=0}';
	var intelligent_signin  = {$intelligent_signin|default=0};
	var qbegold = {$qbegold};
	var virtualname = "{:config('virtualname')}";
	var expire = {:config('sign_expire')};
	var Cbox{$randomStr} = '{$chaptercontent|json_encode}';
	
	$(function(){
		var html ='';
		$.each(eval(Cbox{$randomStr}).reverse(), function(i, v) {
			html +=v;
		})
		$(".read_main_p").html(html);
	})
    $(function () {
		//过滤正文中存在的多余空格
		var content = $('.read_main_p').html();
		content = content.replace(/[　]/g,"");
		content = content.replace(/[ ]/g,"");
		$('.read_main_p').html(content);

        size=Cookies.get('size')?Cookies.get('size'):2;
        $(".read_body").attr("class", "read_body read_body_fontsize_" + size);
        color=Cookies.get('color')?Cookies.get('color'):4;
        $("html,body").attr("class", "read_theme_" +  color);

        //$(".m_f_set_bg_li").eq(color).addClass("m_f_set_bg_elect").siblings(".m_f_set_bg_li").removeClass("m_f_set_bg_elect");
        console.log("#font"+size);
        $("#font"+size).addClass("m_f_set_bg_elect");
        $("#bg"+color).addClass("m_f_set_bg_elect");

        $('.m_f_set_font_main .m_f_set_bg_li:eq('+size+')').addClass("m_f_set_bg_elect");


        if(Cookies.get('black_day')!="")
        {
            $("html,body").addClass(Cookies.get('black_day'));
        }

        $(".menu_evocation_box strong,.op_menu").click(function() {
        $(".menu_box").show()
        });
        var strToday = getTodayString();
		
        // 检查是否签到过
      //window.localStorage.removeItem('last_checkin_date');
        var lastCheckinDate = window.localStorage.getItem('last_checkin_date');
        if (lastCheckinDate !== strToday&&qiandao==0&&intelligent_signin==1) {
            checkin();
        }
		
        function checkin() {
			/**
            $.ajax({
                url: '/index.php/cms/api/addcore/',
                type: 'POST',
                contentType: 'application/json'
            })
                .then(function (result) {
                    setCheckedIn();
                    $.modal({
                        title: '签到成功',
                        text: '<p>每日首次阅读, 赠送 <span style="color:orangered">50</span> 书币</p>' +
                        '<p style="margin-top:10px">请明日继续签到哦</p>',
                        buttons: [
                            {text: '我知道啦'}
                        ]
                    })
                })
                .fail(function (xhr) {
                    var result = JSON.parse(xhr.responseText);
                    // 如果是未关注用户, 第一天无需自动签到, 标记为已签到,以减少后续 API 请求
                    // 如果是重复签到, 说明用户可能是在新设备访问, 补充标记
                    if (result.code === 'not_subscribed' || result.code === 'already_checked_in') {
                        setCheckedIn();
                    }
                });
			**/
			setCheckedIn();
			$.modal({
				title: '签到成功',
				text: '<p>每日首次阅读, 赠送 <span style="color:orangered">'+qbegold+'</span>'+virtualname+'</p>' +
				'<p style="margin-top:10px">请明日继续签到哦</p><p>签到赠送书币有效期为'+expire+'天</p>',
				buttons: [
					{text: '我知道啦'}
				]
			})
        }

        function getTodayString() {
            var date = new Date();
            return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
        }

        function setCheckedIn() {
            window.localStorage.setItem('last_checkin_date', strToday);
        }

        gettuijian();
        function gettuijian() {
			/***
            $.ajax({
                url: '/index.php/cms/api/gettuijian/cid/2',//{{{md5code}}}
                type: 'POST',
                contentType: 'application/json'
            })
                .then(function (result) {
                    if(result.code==200)
                    {
                    var tuijian=template('tuijian-novel-item',result);
                    document.getElementById("tuijian").innerHTML = tuijian;
                    }

                });
			**/
        }
		/***
        getad();
        function getad() {
            $.ajax({
                url: '/index.php/cms/api/getad/',
                type: 'POST',
                contentType: 'application/json'
            })
                .then(function (result) {
                    if(result.code==200)
                    {
                    document.getElementById("vip-btn").innerHTML = result.data;//{{{md5code}}}
                    }

                });
        }
		***/
    });
</script>
<script type="text/html" id="tmpl-gifts">
  <ul class="actionsheet-tip">
    {{#each gifts}}<li>
      <a class="btn-gift" data-gift-id="{{id}}">
        <img src="{{img_url}}" alt="{{title}}">
        <span class="text"><span class="price">{{wealth}}</span>书币</span>
      </a>
    </li>{{/each}}
  </ul>
</script>

<!--打赏-->
<script>
  (function (global) {
    var gifts = [{"id":1,"title":"\u9c9c\u82b1","img_url":"\/public\/static\/cms\/img\/gift_1.jpg","wealth":100},{"id":2,"title":"\u638c\u58f0","img_url":"\/public\/static\/cms\/img\/gift_2.jpg","wealth":388},{"id":3,"title":"\u94bb\u6212","img_url":"\/public\/static\/cms\/img\/gift_3.jpg","wealth":588},{"id":4,"title":"\u6e38\u8f6e","img_url":"\/public\/static\/cms\/img\/gift_4.jpg","wealth":888}];

    global.Tip = function () { };

    _.extend(Tip.prototype, {
      open: function () {
        var me = this;
        $.actions({
          title: '打赏',
          actions: [{
            className: 'bg-white',
            text: HandlebarTemplates.get('tmpl-gifts')({
              gifts: gifts
            })
          }]
        });

        $('.actionsheet-tip').on('click', '.btn-gift', function () {
          var gift = _.find(gifts, { id: parseInt($(this).data('gift-id')) });
          // 由于当actionshhet关闭时，jquery-weui会将modal的遮罩css也一起删除，因此需要做这个hack//{{{md5code}}}
          // https://github.com/lihongxun945/jquery-weui/blob/master/src/js/action.js#L50
          setTimeout(function () {
            me.create(gift);
          }, 50);
        });
      },
      create: function (gift) {
        var me = this;
        $.actions({
          title: '确定打赏?',
          actions: [{
            text: '确定',
            className: 'color-primary',
            onClick: function () {
              $.ajax({
                url: '/index.php/cms/api/settips',
                type: 'POST',
                dataType: 'JSON',
                contentType: 'application/json',
                data: JSON.stringify({
                  gift_id: gift.id,
                  novel_id: 600584,
                  bid:1204                })
              })
              .then(function (payload) {
                $.toast('打赏成功');
                $(document).trigger('inovel.tip.created', payload.data);
              })
              .fail(function (error) {
                // 余额不足
                if (error.responseJSON.code === 9999) {
                  me.recharge(gift);
                } else {
                  $.toast(error.responseJSON.message, 'forbidden');
                }
              });   
            }
          }]
        });
      },
      recharge: function (gift) {
        $.modal({
          title: "余额不足",
          text: " 是否前往充值?",
          buttons: [{ 
            text: "立即充值",
            onClick: function () {
              window.onpageshow = function (e) {
                if (e.persisted) {
                  location.reload();
                }
              };

              location.assign('/pay/index');
            }
          }, { 
            text: "取消",
            className: "default"
          }]
        });
      }
    });
  })(window);
</script>







<!--<script src="//res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>-->
<script>
    var articleId = 600584;
    var __title = '第1卷 官场潜规则 1.不上钱就上人儿';
    var _lk = "";
    var prev_article_id = 0;
    var novel_id = 1204;
    var from = '';
    var ewm='';

    //点击下一张是否提示
    var showFollowPopupOnNext = false;
    //底部按钮提示
    var forceFollow = false;

    if (!forceFollow || showFollowPopupOnNext) {

        getewm();
    }

     function getewm() {
		/***
        $.ajax({
            url: '/index.php/cms/api/ewm/',
            type: 'GET',
            contentType: 'application/json'
        })
            .then(function (data) {
                ewm=data;
            });
		***/
		ewm="{$qrcode}";
    }

    function addBookmark() {
        $.ajax({
            url: '/index.php/cms/api/addbookmark/id/' + articleId,
            type: 'GET',
            contentType: 'application/json'
        })
            .then(function () {
                $.toast('书签添加成功', 1000);
            });
    }

    function openFontsDialog() {
        $.modal({
            title: '字体大小',
            text: $('#template-dialog-fonts').html(),
            buttons: [
                { text: '确定' }
            ]
        });
    }

    function openBackgroundDialog() {
        $.modal({
            title: '背景颜色',
            text: $('#template-dialog-bg').html(),
            buttons: [
                { text: '确定' }
            ]
        });
    }

    function applyFontSize(size) {
        switch (size) {
            case 'large':
                $(".weui_article").css('font-size', "24px");
                break;
            case 'medium':
                $(".weui_article").css('font-size', "20px");
                break;
            case 'small':
                $(".weui_article").css('font-size', "16px");
                break;
        }
      
    }

    function applyBackground(bg) {
        $('body').removeClass('color-dark').removeClass('color-comfortable');
        if (bg !== 'none') {
            $('body').addClass('color-' + bg);
        }
    }

    $(document).ready(function () {
        $('.btn-next-article').click(function () {
            $(".m_f_set_box").removeClass("menu_set_show");
            $(".menu_hide").hide()
            if (showFollowPopupOnNext) {
              		toNext();
                    $.modal({
                        title: '长按识别作者授权公众号继续阅读',
                        text: '<div style="font-size:16px;color:#333">' +
                        '<div style="margin:5px auto;color:red">由于版权问题，<br/>请扫下方二维码继续阅读</div>' +
                        '<img src="'+ewm+'" style="width:70%"/>' +
                        '<div style="font-weight:bold;font-size:18px">长按上图识别二维码</div>' +
                        '</div>'
                    });

                    $('.weui_dialog').css('top', '20%');
            } else {
                location.href = $(this).data('url');
            }
        });
        var tip = new Tip();

        // tip
        var hash = qs2hash(location.search);
        if (hash['tip']) {
            tip.open();
        }

        
        $('#menu').click(function () {
            var actions = [];

            actions.push({
                text: '<i class="iconfont icon-text"></i> 字体大小',
                onClick: openFontsDialog
            });
            actions.push({
                text: '<i class="iconfont icon-color"></i> 背景颜色',
                onClick: openBackgroundDialog
            });
            actions.push({
                text: '<i class="iconfont icon-bookmark"></i> 添加书签',
                onClick: addBookmark
            });

            actions.push({
                text: '<i class="iconfont icon-dashang"></i><span>我要打赏</span>',
                onClick: function () {
                    tip.open();
                }
            });

            actions.push({
                text: '<i class="iconfont icon-menu"></i> 返回目录',
                onClick: function () {
                    location.href = "/index.php/cms/index/chapter/bid/1204.html";
                }
            });

            actions.push({
                text: '<i class="iconfont icon-home"></i> 返回首页',
                onClick: function () {
                    location.href = "/index.php/cms/index/index.html";
                }
            });

            $.actions({
                actions: actions
            });
        });

        $(document).on('click', '.bghover', function () {
            var bg = $(this).data('color');
            applyBackground(bg);
            Cookies.set('bg', bg, { expires: 3 * 365 * 24 * 60 * 60 });
            return false;
        });

        /*$(document).on('click', '.fonthover', function () {
            var size = $(this).data('size');
            applyFontSize(size);
            Cookies.set('size', size, { expires: 3 * 365 * 24 * 60 * 60 });
            return false;
        });*/


        if (!forceFollow) {
           
             initSubscribePanel();       
        }

        function initSubscribePanel() {
          	
          	
            $('#subscribe-panel').show();
				
                $('.btn-subscribe').click(function () {
                  	//alert('');
                  	if('' == 'orntT0SdT9v507U0MR8lDOYa0978'){
            			//toNext();
            		}
                  	toNext();
                    $.modal({
                        title: '作者提示: 如何追书?',
                        text: '<div style="font-size:16px;color:#333">' +
                        '<div style="margin:5px auto;color:red">关注作者授权公众号，方便下次阅读</div>' +
                        '<img src="'+ewm+'" />' +
                        '<div style="font-weight:bold;font-size:18px">长按识别上方二维码关注</div>' +
                        '</div>',
                        buttons: [{'text': '关 闭'}]
                    });
                    //{{{md5code}}}
                    $('.weui_dialog').css('top', '20%');

                    return false;
                });
        }
      
      	function toNext() {
            $.ajax({
                url: '/index.php/cms/api/tonextzj/zid/600588/bid/1204.html',//{{{md5code}}}
                type: 'POST',
                contentType: 'application/json'
            })
              .then(function (result) {
                  if(result.code==200)
                  {
                  }
            });
      	}
 
        // read user settings from cookie
         if (Cookies.get('size')) {
            applyFontSize(Cookies.get('size'));
        }
        if (Cookies.get('bg')) {
            applyBackground(Cookies.get('bg'));
        }

    
       
    });
</script>


<!-- 这里引入js -->
<script type="text/javascript">
$(function() {
    //var a = $.fn.cookie("cs");
    var a=[];
    a && (1 == a.l ? $(".ocs span").addClass("read_reverse_sequence").text("\u5012\u5e8f") : $(".ocs span").removeClass("read_reverse_sequence").text("\u6b63\u5e8f"));
    $(".read_catalog_list").on("click", ".read_catalog_tit span",
    function() {
        var b = $.fn.cookie("cs"),
        a = $(".read_catalog_ul li"),
        d = $("<ul></ul>");
        b = b ? fRead.jsonparse(b) : cs;
        1 == b.l ? (b.l = 2, $(".read_catalog_tit span").addClass("read_reverse_sequence").text("\u5012\u5e8f")) : (b.l = 1, $(".read_catalog_tit span").removeClass("read_reverse_sequence").text("\u6b63\u5e8f"));
        for (var e = a.length - 1; 0 <= e; e--) d.append(a.eq(e));
        $(".read_catalog_ul").html("");
        $(".read_catalog_ul").html(d.html());
        $.fn.cookie("cs", fRead.jsonstringify(b), {
            expires: 30,
            path: "/"
        })
    });
    $(".m_f_catalog").click(function() {});
    $(".menu_evocation_box strong,.op_menu").click(function() {
        $(".menu_box").show()
    });
    $(".menu_box i").click(function() {
        $(".m_f_set_box").removeClass("menu_set_show");
        $(".menu_hide").hide()
    });
    $(".m_f_set").click(function() {
        $(".m_f_set_box").toggleClass("menu_set_show")
    });
    $(".m_f_set_font_main .m_f_set_bg_li").click(function() {
        var b = $(this),
        //a = $.fn.cookie("cs"),
        d = b.index();
        Cookies.set('size', d);
        //a = a ? fRead.jsonparse(a) : cs;
       // a.f = d; 
        $(".read_body").attr("class", "read_body read_body_fontsize_" + d);
        b.addClass("m_f_set_bg_elect").siblings(".m_f_set_bg_li").removeClass("m_f_set_bg_elect");
        /*$.fn.cookie("cs", fRead.jsonstringify(a), {
            expires: 30,
            path: "/"
        })*/
    });
    $(".m_f_set_bg_main .m_f_set_bg_li").click(function() {
        var a = $(this),
        //c = $.fn.cookie("cs"),
        d = a.index();
        //c = c ? fRead.jsonparse(c) : cs;
        //c.b = d;
        //c.d = 1;
        Cookies.set('color', d);
        $("html,body").attr("class", "read_theme_" + d);
        a.addClass("m_f_set_bg_elect").siblings(".m_f_set_bg_li").removeClass("m_f_set_bg_elect");
        /*$.fn.cookie("cs", fRead.jsonstringify(c), {
            expires: 30,
            path: "/"
        })*/
    });
    $(".m_f_night_day").click(function() {
        //var a = $.fn.cookie("cs");
        //a = a ? fRead.jsonparse(a) : cs;
        if($('.read_theme_5').length>0)
        {
            Cookies.set('black_day', "");
        }
        else{
            Cookies.set('black_day', "read_theme_5");
        }
        
        1 == a.d ? ($("html,body").addClass("read_theme_5"), a.d = 2) : ($("html,body").removeClass("read_theme_5"), a.d = 1);
        /*$.fn.cookie("cs", fRead.jsonstringify(a), {
            expires: 30,
            path: "/"
        })*/
    });
    $(".read_catalog_box i").click(function() {
        $(".read_catalog_box").removeClass("read_catalog_show")
    });
    $(".read_other_but_r").click(function() {
        $("#fiexd_ewm_box").show()
    });
    $(document).on("click", ".gzewm",
    function(a) {
        if (2 != $.fn.cookie("tiao")) return $("#fiexd_ewm_box").show(),
        a.stopPropagation(),
        $.fn.cookie("tiao", 2, {
            expires: 1,
            path: "/"
        }),
        !1
    });
    $(".f_main_cloes,.f_main_over,.f_main_cloes_2").click(function() {
        $(".fiexd_ewm_box").hide()
    });
    $(document).on("click", ".r_img_list_edit a",
    function(a) {
        a.stopPropagation();
        return ! 1
    })
});
</script>
{/block}